﻿using Autofac;
using Treca.Util.DllInit;
using Treca.Util.PublishSubscribe;
using Treca.CHCSDK.Services.FaceRecognition;
using Treca.Util;using System;
using Treca.CHCSDK.Services.SdkManager;
using Treca.CHCSDK.Services.FaceRecognition.Services;
using Microsoft.AspNetCore.SignalR;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Reflection;
using Newtonsoft.Json.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using EFCore.Sharding;
using System.Linq;
using Treca.Business.Base_SysManage;
using System.Xml.Linq;
using Treca.Util.Kafka;
using System.Threading;
using Treca.PushMessage.Base;

namespace Treca.Message
{

        public class PushMessageModule : DLLInit
        {
        public static bool IsKafkaService = false;
        public override void ConfigureContainer(ContainerBuilder builder)
        {
            builder.RegisterType<PMServiceContainer>();
        }
        public override void ConfigureServices(IServiceCollection service)
        {
            //service.AddTransient<ZhMessageEvent>();
        }
        public override void DLLStart()
        {
            //CreateMoJob createMoJob = AutofacHelper.GetScopeService<CreateMoJob>();
            //createMoJob.Execute(null);
            //BaseEntity1 baseEntity = new BaseEntity1();
            //baseEntity["qwee"] = 1;
            //var json = JsonConvert.SerializeObject(baseEntity);
            //SdkPubSubCenter.AddSubscribe<RegisterEvent,cbg_register>("DriverRegister");
            if (IsKafkaService)
            {
                IKafkaService kafkaService = AutofacHelper.GetScopeService<IKafkaService>();
                kafkaService.SubscribeAsync<string>(new List<string> { "test" }, (str) =>
                {

                }, CancellationToken.None);
            }
            //try
            //{
            //    var LocalIp = Treca.Util.Tools.GetSection("AppConfig", "LocalIp1");
            //    var ServerPort = Treca.Util.Tools.GetSection("AppConfig", "ServerPort");
            //    var ServiceName = Treca.Util.Tools.GetSection("AppConfig", "ServiceName");
            //    var ConsulUrl = Treca.Util.Tools.GetSection("AppConfig", "ConsulUrl1");
            //    if (!ConsulUrl.IsNullOrEmpty())
            //    {
            //        ConsulHelper.RegisterConsul(ConsulUrl, ServiceName, LocalIp, ServerPort);
            //    }
            //}
            //catch (Exception ex)
            //{
            //    LogHelper.WriteLog_LocalTxt(ex.Message);
            //}
        }


    }
}
